/*
package com.github.binarywang.demo.wx.miniapp.controller;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import cn.binarywang.wx.miniapp.message.WxMaMessageRouter;
import com.github.binarywang.demo.wx.miniapp.config.WxMaProperties;
import com.github.binarywang.demo.wx.miniapp.utils.HttpClientUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


*/
/**
 * 推送
 *//*

@RestController
@AllArgsConstructor
@RequestMapping("/wx/push")
@Slf4j
public class WxPushController {

    private final WxMaProperties properties;

    private final WxMaService wxMaService;
    private final WxMaMessageRouter wxMaMessageRouter;

    //获取openId
    @GetMapping("/wxcallback")
    public void wxcallback(String code) throws IOException {
        // 第二步：通过code换取网页授权access_token
        */
/*String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + properties.getConfigs().get(0).getAppid() +
            "&secret=" + properties.getConfigs().get(0).getSecret() +
            "&js_code=" + code +
            "&grant_type=authorization_code";
        JSONObject jsonObject = HttpClientUtils.doGet(url);

        String openid = jsonObject.getString("openid"); *//*

        WxMaJscode2SessionResult sessionResult =null;
        try {
            sessionResult = wxMaService.jsCode2SessionInfo(code);
        } catch (WxErrorException e) {
            e.printStackTrace();
        }
        System.out.println(sessionResult.getOpenid());
    }

    //发送通知
    @GetMapping("/send")
    public void testSendSubscribeMsg(String openId) throws WxErrorException {

        List<WxMaSubscribeMessage.MsgData> list = new ArrayList<>();List<WxMaSubscribeMessage.MsgData> dataList = new ArrayList<>();
        WxMaSubscribeMessage.MsgData data1 = new WxMaSubscribeMessage.MsgData();
        data1.setName("thing1");
        data1.setValue("222");
        list.add(data1);
        WxMaSubscribeMessage.MsgData data2 = new WxMaSubscribeMessage.MsgData();
        data2.setName("thing4");
        data2.setValue("222");
        list.add(data2);

        WxMaSubscribeMessage wxMaSubscribeMessage = WxMaSubscribeMessage.builder()
            .toUser(openId)
            .templateId("pMH8JpP4RCq0zfyn-u8n-MqU_QhwP3aVS4zyajj7KH8")
            .page("")
            .data(list)
            .build();
        wxMaService.getSubscribeService().sendSubscribeMsg(wxMaSubscribeMessage);
    }


}
*/
